﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace GamePrep
{
    public class ConsoleDrawer
    {
        public ConsoleDrawer()
        {
            Console.CursorVisible = false;
        }

        public static void DrawGameField(GameField gf, char ch)
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            for (int i = 0; i < gf.Width+2; i++)
            {
                for (int j = 0; j < gf.Height+2; j++)
                {
                    Console.SetCursorPosition(i + (gf.X-1), j + (gf.Y-1));
                    if (i == 0 || i == gf.Width +1)
                    {
                        
                        Console.Write(ch);
                    }
                    else if (j == 0 || j == gf.Height +1)
                    {
                        Console.Write(ch);
                    }
                    else
                    {
                        Console.Write(' ');
                    }
                }
                
                Console.WriteLine();
            }
            Console.ForegroundColor = ConsoleColor.White;
        }

        public void DrawGameNode(GameNode newGameNode)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.SetCursorPosition(newGameNode.X, newGameNode.Y);
            Console.Write(newGameNode.nodeSymbol);
            Thread.Sleep(50);
            Console.ForegroundColor = ConsoleColor.White;
        }

        public void ClearGameNode(GameNode newGamenode)
        {
            Console.SetCursorPosition(newGamenode.X, newGamenode.Y);
            Console.Write(' ');
            Thread.Sleep(50);
        }

        public void DrawTarget(GameNode newGameNode)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.SetCursorPosition(newGameNode.X, newGameNode.Y);
            Console.Write(newGameNode.nodeSymbol);
            Console.ForegroundColor = ConsoleColor.White;
        }


    }
}
